package org.apache.shiro.web.tags;

import org.apache.shiro.subject.Subject;

public class HasAnyPermissionTag extends PermissionTag {

	/**
	 * 
	 */
	private static final long serialVersionUID = 4139937870852372961L;
	private static final String PERMISSION_NAMES_DELIMETER = ",";
	
	@Override
	protected boolean showTagBody(String permissions) {
		boolean hasAnyPermission = false;  
        Subject subject = getSubject();  
        if (subject != null) {  
        	String[] permissionArr = permissions.split(PERMISSION_NAMES_DELIMETER);
            for (String permission : permissionArr) {  
                if (subject.isPermitted(permission.trim())) {  
                    hasAnyPermission = true;  
                    break;  
                }  
            }  
        }
        
        return hasAnyPermission; 	
    }

}
